package com.fjwt.gz.service.impl;

import com.alibaba.fastjson2.JSONObject;
import com.fjwt.gz.db.entity.StatActivityAgentNumEntity;
import com.fjwt.gz.service.mapper.StatActivityAgentNumMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 活动机构统计表：参与人数、人次 服务实现类
 * </p>
 *
 * @author wangjie
 * @since 2025-08-13
 */
@Slf4j
@Service
public class StatActivityAgentNumService extends ServiceImpl<StatActivityAgentNumMapper, StatActivityAgentNumEntity> {

    public JSONObject aggregateQuery(String agentNo) {
        List<StatActivityAgentNumEntity> one = baseMapper.aggregateQuery(agentNo);
        JSONObject jsonObject = new JSONObject();
        int totalNum = 0;
        for (StatActivityAgentNumEntity statActivityAgentNumEntity : one){
            JSONObject json = new JSONObject();
            json.put("activityNum", statActivityAgentNumEntity.getActivityNum());
            totalNum = totalNum + statActivityAgentNumEntity.getActivityNum();
            jsonObject.put(statActivityAgentNumEntity.getActivityTypeNo(), json);
        }
        jsonObject.put("totalNum", totalNum);
        return jsonObject;
    }
    public List<StatActivityAgentNumEntity> aggregateQueryFilter(String agentNo) {
        List<StatActivityAgentNumEntity> one = baseMapper.aggregateQueryFilter(agentNo);
        return one;
    }

    public List<StatActivityAgentNumEntity> activityStatisticsListNum() {
        return baseMapper.activityStatisticsListNum();
    }

}
